﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Kenly.DBFramework.Gateway
{
    /// <summary>
    /// 
    /// </summary>
    [Serializable]
    public class RuleViolation
    {
        /// <summary>
        /// 
        /// </summary>
        public object Entity
        {
            get;
            private set;
        }

        /// <summary>
        /// 
        /// </summary>
        public string PropertyName
        {
            get;
            private set;
        }

        /// <summary>
        /// 
        /// </summary>
        public string ErrorMessage
        {
            get;
            private set;
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="errorMessage"></param>
        public RuleViolation(string errorMessage):
            this(errorMessage,"",null)
        {
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="errorMessage"></param>
        /// <param name="propertyName"></param>
        public RuleViolation(string errorMessage, string propertyName):
            this(errorMessage,propertyName,null)
        {
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="errorMessage"></param>
        /// <param name="propertyName"></param>
        /// <param name="entity"></param>
        public RuleViolation(string errorMessage, string propertyName, object entity)
        {
            this.ErrorMessage = errorMessage;
            this.PropertyName = propertyName;
            this.Entity = entity;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return this.ErrorMessage;
        }
    }
}
